<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Sets the object in which to resolve callback functions</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.xslt-set-log.html">xslt_set_log</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.xslt-set-sax-handler.html">xslt_set_sax_handler</a></div>
 <div class="up"><a href="ref.xslt.html">XSLT (PHP 4) 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.xslt-set-object" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">xslt_set_object</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.3.0)</p><p class="refpurpose"><span class="refname">xslt_set_object</span> &mdash; <span class="dc-title">Sets the object in which to resolve callback functions</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.xslt-set-object-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">bool</span> <span class="methodname"><strong>xslt_set_object</strong></span>
    ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$processor</code></span>
   , <span class="methodparam"><span class="type">object</span> <code class="parameter reference">&$obj</code></span>
   )</div>

  <p class="para rdfs-comment">
   This function allows to use the <em><code class="parameter">processor</code></em> inside
   an <em><code class="parameter">object</code></em> and to resolve all callback functions
   in it.
  </p>
  <p class="para">
   The callback functions can be declared with
   <span class="function"><a href="function.xslt-set-sax-handlers.html" class="function">xslt_set_sax_handlers()</a></span>,
   <span class="function"><a href="function.xslt-set-scheme-handlers.html" class="function">xslt_set_scheme_handlers()</a></span> or
   <span class="function"><a href="function.xslt-set-error-handler.html" class="function">xslt_set_error_handler()</a></span> and are assumed to be methods
   of <em><code class="parameter">object</code></em>.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.xslt-set-object-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    <dt>
<em><code class="parameter">
processor</code></em></dt>
<dd>
<p class="para"><acronym title="eXtensible Stylesheet Language Transformations">XSLT</acronym> 处理器连接标识符，由
<span class="function"><a href="function.xslt-create.html" class="function">xslt_create()</a></span> 创建。</p></dd>


    
     <dt>
<em><code class="parameter">obj</code></em></dt>

     <dd>

      <p class="para">
       An object.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.xslt-set-object-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功时返回 <strong><code>TRUE</code></strong>， 或者在失败时返回 <strong><code>FALSE</code></strong>。
  </p>
 </div>


 
 <div class="refsect1 description" id="refsect1-function.xslt-set-object-description">
  <h3 class="title">范例</h3>
  <div class="example" id="example-5437">
   <p><strong>Example #1 Using your own error handler as a method</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #007700">class&nbsp;</span><span style="color: #0000BB">my_xslt_processor&nbsp;</span><span style="color: #007700">{<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;</span><span style="color: #0000BB">$_xh</span><span style="color: #007700">;&nbsp;</span><span style="color: #FF8000">//&nbsp;our&nbsp;XSLT&nbsp;processor<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">my_xslt_processor</span><span style="color: #007700">()<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">_xh&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">xslt_create</span><span style="color: #007700">();<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;Make&nbsp;$this&nbsp;object&nbsp;the&nbsp;callback&nbsp;resolver<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">xslt_set_object</span><span style="color: #007700">(</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">_xh</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">);<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;Let's&nbsp;handle&nbsp;the&nbsp;errors<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">xslt_set_error_handler</span><span style="color: #007700">(</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">_xh</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"my_xslt_error_handler"</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;</span><span style="color: #0000BB">my_xslt_error_handler</span><span style="color: #007700">(</span><span style="color: #0000BB">$handler</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$errno</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$level</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$info</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;for&nbsp;now,&nbsp;let's&nbsp;just&nbsp;see&nbsp;the&nbsp;arguments<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">func_get_args</span><span style="color: #007700">());<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

  </div>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.xslt-set-log.html">xslt_set_log</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.xslt-set-sax-handler.html">xslt_set_sax_handler</a></div>
 <div class="up"><a href="ref.xslt.html">XSLT (PHP 4) 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
